package com.bdy.lm.taximanager.ui;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import com.bdy.lm.taximanager.R;
import com.bdy.lm.taximanager.model.DriverInfo;

import java.util.List;
import java.util.Map;

public class MessageContentActivity extends FragmentActivity {

    private ViewPager viewPager;
    private List<Map<String, String>> msgList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        viewPager = new ViewPager(this);
        viewPager.setId(R.id.viewPager);
        setContentView(viewPager);

        Bundle bundle = this.getIntent().getExtras();
        int i = bundle.getInt("msgLoc");
        msgList = (List<Map<String, String>>) bundle.getSerializable("msgList");

        FragmentManager fm = getSupportFragmentManager();

        viewPager.setAdapter(new FragmentStatePagerAdapter(fm) {
            @Override
            public Fragment getItem(int position) {
                return MessageContentFragment.newInstance(msgList.get(position));
            }

            @Override
            public int getCount() {
                return msgList.size();
            }

//            @Override
//            public int getItemPosition(Object object) {
//                return POSITION_NONE;   // 返回发生改变，让系统重新加载
//                // 系统默认返回的是     POSITION_UNCHANGED，未改变
//                // return super.getItemPosition(object);
//            }
        });
        viewPager.setCurrentItem(i);

    }
}
